<?php
$xmlstr = <<<XML
<?xml version="1.0"?>
<root>
      <articol>
              <title>Nice</title>
              <author>Gates</author>
              <date>2008-01-01</date>
              <content>
                        <image id="2">headline.jpg</image>
                        <image id="4">gates_kewl.jpg</image>
              </content>
      </articol>
</root>
XML;
$root = new SimpleXMLElement($xmlstr);
foreach ($root->articol->content->image as $img) {
    switch((string) $img['id']) { // Get attributes as element indices
    case '4':
        echo $img;
        break;
    }
}
?>